/*
 * luafont.cpp
 * This file is part of OpenAnimator
 *
 * Copyright (C) 2008 - Abhinav Lele
 *
 * OpenAnimator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OpenAnimator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenAnimator; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */
 
 
#include "common.h"
#include "luafont.h"

/** Draw some text. Parameters : fontname, fontsize, rendertext. On error returns nil*/
int XLUA_DrawText(lua_State *L) {

	if(!(API_ARGCHECK(IS_STRING,L,ARG3_1) & API_ARGCHECK(IS_NUMBER,L,ARG3_2) & API_ARGCHECK(IS_STRING,L,ARG3_3))) return 0;

	string fontname,rendertext;
	int fontsize;

	fontname = string(lua_tostring(L,ARG3_1));
	fontsize = lua_tonumber(L, ARG3_2);
	rendertext = string(lua_tostring(L, ARG3_3));

	FTGLPixmapFont font(fontname.c_str());
	if(font.Error()) return 0;
	font.FaceSize(fontsize);
	font.Render(rendertext.c_str());
	lua_pushnumber(L,1);
}
